<template>
  <search-bar @keyword="search"></search-bar>
  <nav-bar :cates="cates" :size="4"></nav-bar>
  <carousel></carousel>
  <cate-products
    :cate="cate"
    v-for="cate in cates.slice(0, 5)"
    :key="cate.cateId"
  ></cate-products>
  <guess :products="newGoods"></guess>
  <hot-top :products="saleGoods"></hot-top>
</template>

<script>
// @ is an alias to /src
import { mapGetters } from "vuex";
import { http } from "../utils/http";
import SearchBar from "../components/SearchBar.vue";
import NavBar from "../components/NavBar.vue";
import Carousel from "../components/Carousel.vue";
import CateProducts from "../components/CateProducts.vue";
import Guess from "../components/Guess.vue";
import HotTop from "../components/HotTop.vue";
export default {
  name: "Home",
  components: {
    SearchBar,
    NavBar,
    Carousel,
    CateProducts,
    Guess,
    HotTop,
  },
  computed: {
    ...mapGetters({
      cates: "cate/cates"
    }),
  },
  data(){
    return {
      saleGoods: [],
      newGoods: [],
	}
  },
  methods: {
    search(keyword) {
      this.$router.push({
        name: "Search",
        query: { keyword: keyword },
        props: true,
      });
    },
  },
  created() {
	http.get( "/goods/getNewGoods").then((resp) => {
          this.newGoods=resp.data.newGoods; 
        })
	http.get( "/goods/getSalesGoods").then((resp) => {
        this.saleGoods=resp.data.salesGoods;
        })
    if (this.cates.length == 0) {
      this.$store.dispatch("cate/fetchCates");
    }
  },
};
</script>
<style>
@charset "UTF-8";

* {
	padding: 0;
	margin: 0
}

body {
	background-color: #f5f5f5;
}

a:hover {
	font-weight: bold;
}

#info {
	color: #fff;
	border-radius: 0;
	background-color: #ff053b;
	border-bottom-color: transparent !important;
	box-shadow: 0 2px 4px 0 rgb(0 0 0/ 12%);
	border-bottom-color: transparent !important;
	background-color: #ff053b;
	border-radius: 0;
}

#info li a {
	color: #fff;
}

#info .badge {
	color: #000;
	background-color: #fff;
	border-radius: 100%;
}

#info .breadcrumb>li+li:before {
	color: #fff;
}

.container-fluid {
	padding: 0;
}

.container-fluid .row {
	margin: 0;
}

div {
	display: block;
}

ul, li {
	list-style: none;
	padding: 0;
	margin: 0;
}

.col-md-12 {
	padding: 0;
}

.search-wrapper {
	padding: 50px 0;
}

.search-form {
	width: 100%;
	border: solid #FF0036;
	display: flex;
}

.search-input {
	flex: 1;
	height: 36px;
	border: none;
	background: 0;
	color: #000;
	background: 0;
	outline: none;
	margin: 0;
	padding: 5px 3px 5px 5px;
}

.search-btn {
	width: 132px;
	height: 36px;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: 5px;
	cursor: pointer;
	color: #fff;
	background-color: #FF0036;
	overflow: hidden;
	border: 0;
	outline: none;
	margin: 0;
	padding-left: 14px;
}

.cate-nav {
	display: flex;
	height: 36px;
	font-weight: 500;
	font-size: 16px;
	color: #333;
	line-height: 36px;
	font-size: 16px;
	color: #333;
}

.cate-nav, .cate-nav li {
	list-style: none;
}

.cate-nav a {
	display: block;
	height: 36px;
	line-height: 36px;
	text-decoration: none;
	color: #333;
	padding: 0 20px;
	text-align: center;
}

.cate-nav li.cate {
	color: #f0f0f0;
	text-align: center;
	width: 150px;
	background-color: #C60A0A;
	position: relative;
	margin-right: 10px;
}

.cate-nav #dropdown_cate {
	padding: 9px 0;
	position: absolute;
	top: 36px;
	left: 0;
	z-index: 1;
	background-color: rgba(0, 0, 0, .55);
	width: 150px;
	position: absolute;
}

.cate-nav #dropdown_cate a {
	color: #fff;
}

.cate-nav .dropdown-menu {
	min-width: 130px;
}

.cate-nav .dropdown-menu li a {
	color: #333;
	height: auto;
}

#myCarousel .carousel-indicators {
	display: flex;
	justify-content: center;
	align-items: center;
}

#myCarousel .carousel-indicators li {
	background: #000;
	width: 25px;
	height: 5px;
	opacity: .3;
	border: none;
	border-radius: 0;
	display: inline-block;
	overflow: hidden;
	margin-left: 5px;
}

#myCarousel .carousel-indicators li.active {
	background: #fff;
	opacity: .6;
}

.panel.home-goods {
	background: none;
	border: none;
	box-shadow: none;
}

.panel.home-goods h3::before {
	content: " ";
	display: block;
}

.panel.home-goods .panel-heading h3 {
	position: relative;
	padding-left: 20px;
	color: #000;
}

.panel.home-goods .panel-heading h3  a {
	color: #999;
}

.panel.home-goods .panel-heading h3::before {
	position: absolute;
	top: 50%;
	left: 0;
	transform: translateY(-50%);
	content: " ";
	display: inline-block;
	background-color: #333;
	width: 5px;
	height: 22px;
}

.carousel .item {
	background: transparent;
}

.carousel-control {
	background-image: none !important;
	width: 5%;
}

#bottomNav>div {
	padding: 200px 0;
}

#bottomNav a {
	color: #929292;
}

.thumbnail {
	border: none;
	border-radius: 0;
}

.cate-wrapper {
	display: flex;
	justify-content: center;
}

.cate-wrapper .cate-item {
	background-color: #fff;
	position: relative;
	z-index: 0;
	padding: 1px;
}

.cate-item::after {
	content: " ";
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: -1;
}

.cate-item:hover::after {
	border: 1px solid #ff053b
}

.cate-wrapper .cate-item a {
	color: #777;
}

.cate-wrapper .cate-item a:hover {
	font-weight: bold;
	text-decoration: none;
}

.breadcrumb {
	margin-bottom: 0
}

.list-group-item.active, .btn-primary {
	background-color: #FF0036 !important;
	border-color: #FF0036 !important;
}
</style>
